package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyCustCdsd;
import com.ruoyi.buss.qmcy.service.IQmcyCustCdsdService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 支行存贷时点Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/cdsd")
public class QmcyCustCdsdController extends BaseController
{
    @Autowired
    private IQmcyCustCdsdService qmcyCustCdsdService;

    /**
     * 查询支行存贷时点列表
     */
    @PreAuthorize(hasPermi = "buss:cdsd:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyCustCdsd qmcyCustCdsd)
    {
        startPage();
        List<QmcyCustCdsd> list = qmcyCustCdsdService.selectQmcyCustCdsdList(qmcyCustCdsd);
        return getDataTable(list);
    }

    /**
     * 导出支行存贷时点列表
     */
    @PreAuthorize(hasPermi = "buss:cdsd:export")
    @Log(title = "支行存贷时点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyCustCdsd qmcyCustCdsd) throws IOException
    {
        List<QmcyCustCdsd> list = qmcyCustCdsdService.selectQmcyCustCdsdList(qmcyCustCdsd);
        ExcelUtil<QmcyCustCdsd> util = new ExcelUtil<QmcyCustCdsd>(QmcyCustCdsd.class);
        util.exportExcel(response, list, "支行存贷时点数据");
    }

    /**
     * 获取支行存贷时点详细信息
     */
    @PreAuthorize(hasPermi = "buss:cdsd:query")
    @GetMapping(value = "/{xfsjc}")
    public AjaxResult getInfo(@PathVariable("xfsjc") String xfsjc)
    {
        return AjaxResult.success(qmcyCustCdsdService.selectQmcyCustCdsdById(xfsjc));
    }

    /**
     * 新增支行存贷时点
     */
    @PreAuthorize(hasPermi = "buss:cdsd:add")
    @Log(title = "支行存贷时点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyCustCdsd qmcyCustCdsd)
    {
        return toAjax(qmcyCustCdsdService.insertQmcyCustCdsd(qmcyCustCdsd));
    }

    /**
     * 修改支行存贷时点
     */
    @PreAuthorize(hasPermi = "buss:cdsd:edit")
    @Log(title = "支行存贷时点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyCustCdsd qmcyCustCdsd)
    {
        return toAjax(qmcyCustCdsdService.updateQmcyCustCdsd(qmcyCustCdsd));
    }

    /**
     * 删除支行存贷时点
     */
    @PreAuthorize(hasPermi = "buss:cdsd:remove")
    @Log(title = "支行存贷时点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{xfsjcs}")
    public AjaxResult remove(@PathVariable String[] xfsjcs)
    {
        return toAjax(qmcyCustCdsdService.deleteQmcyCustCdsdByIds(xfsjcs));
    }
}
